#!/bin/bash

S_USER='root' #special user
DEBUG=1

if [ "$USER" != "$S_USER" ]; then
	echo -e '\033[31;5mMust run the script as '$S_USER'!\033[0m'
	exit 1
fi

if [ $DEBUG -eq 1 ]; then
	STDOUT=`tty`
	STDERR=`tty`
else
	STDOUT=/tmp/${0##*/}.log
        STDERR=/tmp/${0##*/}.log
fi


if [ "$0" = "bash" ]; then
	BASEDIR="$(dirname `history |tail -1|awk '{print $3}'`)"

else
	BASEDIR="$(dirname $0)"
fi

[ -z "$BASEDIR" ] && echo "Exec error!" && exit 1

if [ "$1" = "--force" ]; then
	force="--force --nodeps" 
else 
	force=
fi


echo BASEDIR: $BASEDIR
echo Shell: $SHELL
echo USER: $USER
echo USER ID: $UID
echo Shell PID: $$
echo Script: $0
echo ARGC: $#
echo ARGS: $@
echo ARGS As One: "$*"
echo TTY: `tty`
echo STDOUT: $STDOUT
echo STDERR: $STDERR
echo ARG10: ${10}
echo ARG-force: $force
